package com.example.springaop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Slf4j
@Aspect
@Component
public class AspectTest {
    @Around("@annotation(com.example.springaop.TimeRecord)")
    public Object test(ProceedingJoinPoint pj){
        long st = System.currentTimeMillis();
        Object result = null;
        try{
            result = pj.proceed();
        } catch (Throwable e) {
            log.info("e:{}",e);
        }
        log.info("cost_time:"+(System.currentTimeMillis()-st)+"ms");
        return result;
    }
}
